import { ConfigManager } from "../../../com/gengine/resource/ConfigManager";
type int = number;
//class ExperienceConfig
    
    export  class ExperienceConfig
    {
        constructor()
        {
            
            this._map = new Map<any, any> /* flash.utils.Dictionary */();
            this._levelMap = new Map<any, any> /* flash.utils.Dictionary */();
            if (ExperienceConfig._instance != null) 
            {
                throw new Error(" ResConfig 单例 ");
            }
            this.init();
            return;
        }

        /* internal  */write(arg1: Object): void
        {
            var loc1=null;
            var loc2=0;
            var loc3=arg1;
            for(loc1 of loc3) 
            {
                this._map[loc1.level] = loc1.upgradeNeedExperience;
            }
            return;
        }

        public init(): void
        {
            var loc1=ConfigManager.instance.getJSONByFileName("t_experience.json");
            this.write(loc1);
            return;
        }

        public getValueByLevel(arg1: int): number
        {
            return this._map[arg1];
        }

        public getTotalByLevel(arg1: int): number
        {
            var loc1=NaN;
            var loc2=null;
            if (this._levelMap[arg1] == null) 
            {
                loc1 = 0;
                var loc3=0;
                var loc4=this._map;
                for (loc2 in loc4) 
                {
                    if (!(int(loc2) < arg1)) 
                    {
                        continue;
                    }
                    loc1 = loc1 + int(this._map[loc2]);
                }
                this._levelMap[arg1] = loc1;
            }
            return this._levelMap[arg1];
        }

        public getLevelByExp(arg1: number): int
        {
            var loc3=NaN;
            var loc1=0;
            var loc2=100;
            while (loc2 > loc1) 
            {
                loc3 = this.getTotalByLevel((loc2 - 1));
                if (arg1 >= loc3) 
                {
                    return loc2;
                }
                --loc2;
            }
            return loc2;
        }

        public static get instance(): ExperienceConfig
        {
            if (ExperienceConfig._instance == null) 
            {
                ExperienceConfig._instance = new ExperienceConfig();
            }
            return ExperienceConfig._instance;
        }

        /* internal */ /* var */_map: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ /* var */_levelMap: Map<any, any> /* flash.utils.Dictionary */;

        /* internal */ static /* var */_instance: ExperienceConfig;
    }
